<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/taglibs.jsp" %>

<h1>
	<fmt:message key="user.view.addbutton" />
</h1>
<c:url var="viewUsersUrl" value="/admin/user/list" />
<a href="${viewUsersUrl}"><fmt:message key="user.view.title" />
</a>
<br />
<br />
<c:url var="saveUserUrl" value="/admin/user/save" />
<form:form modelAttribute="user" method="POST" action="${saveUserUrl}">
	<form:hidden path="id" />
	<form:hidden path="addressHome.id" />
	<table collspadding="0px" border="0px" width="800px">
		<tr>
			<td colspan="3">
				<c:if test="${_messages_!=null}">
					<fmt:message key="${_messages_}" /><br>
				</c:if>
				<ul>
				<c:forEach items="${_errors_}" var="error">
				<li><fmt:message key="${error}" /></li>
			 	</c:forEach> 
				</ul>
			</td>
		</tr>
		<tr>
			<td width="80px"><form:label path="username">
					<fmt:message key="user.form.username" />:</form:label>
			</td>
			<td width="200px"><form:input path="username" />
			</td>
			<td width="200px">
				<form:errors path="username" cssClass="formerror" />
			</td>
		</tr>
		<tr>
			<td><form:label path="password">
					<fmt:message key="user.form.password" />:</form:label>
			</td>
			<td><form:password path="password" />
			</td>
			<td><form:errors path="password" cssClass="formerror" />
			</td>
		</tr>
		<tr>
			<td><form:label path="firstName">
					<fmt:message key="user.form.firstname" />:</form:label>
			</td>
			<td><form:input path="firstName" />
			</td>
			<td><form:errors path="firstName" cssClass="formerror" />
			</td>
		</tr>
		<tr>
			<td><form:label path="surname">
					<fmt:message key="user.form.surname" />:</form:label>
			</td>
			<td><form:input path="surname" />
			</td>
			<td><form:errors path="surname" cssClass="formerror" />
			</td>
		</tr>
		<tr>
			<td><form:label path="email">
					<fmt:message key="user.form.email" />:</form:label>
			</td>
			<td><form:input path="email" />
			</td>
			<td><form:errors path="email" cssClass="formerror" />
			</td>
		</tr>
		<tr>
			<td><form:label path="telephone">
					<fmt:message key="user.form.telephone" />:</form:label>
			</td>
			<td><form:input path="telephone" />
			</td>
			<td></td>
		</tr>
		<tr>
			<td><form:label path="addressHome.streetNumber">
					<fmt:message key="user.form.streetnumber" />:</form:label>
			</td>
			<td><form:input path="addressHome.streetNumber" />
			</td>
			<td></td>
		</tr>
		<tr>
			<td><form:label path="addressHome.street">
					<fmt:message key="user.form.street" />:</form:label>
			</td>
			<td><form:input path="addressHome.street" />
			</td>
			<td></td>
		</tr>
		<tr>
			<td><form:label path="addressHome.city">
					<fmt:message key="user.form.city" />:</form:label>
			</td>
			<td><form:input path="addressHome.city" />
			</td>
			<td></td>
		</tr>
		<tr>
			<td><form:label path="addressHome.zip">
					<fmt:message key="user.form.zip" />:</form:label>
			</td>
			<td><form:input path="addressHome.zip" />
			</td>
			<td></td>
		</tr>
		<tr>
			<td><form:label path="addressHome.state">
					<fmt:message key="user.form.state" />:</form:label>
			</td>
			<td><form:input path="addressHome.state" />
			</td>
			<td></td>
		</tr>
		<tr>
			<td><form:label path="addressHome.country">
					<fmt:message key="user.form.country" />:</form:label>
			</td>
			<td><form:select path="addressHome.country"
					items="${countryList}" />
			</td>
			<td></td>
		</tr>
		<tr>
			<td colspan="3"><hr />
			</td>
		</tr>
		<tr>
			<td><form:label path="roles">
					<fmt:message key="user.form.role" />:</form:label>
			</td>
			<td><form:select path="roles" multiple="true"
					items="${rolelist}" itemValue="id" itemLabel="name" /></td>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" value="Save User" />
			</td>
			<td></td>
		</tr>
	</table>
</form:form>
